<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 
    template="./../WEB-INF/templade.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"  
    xmlns:h="http://java.sun.com/jsf/html"  
    xmlns:p="http://primefaces.prime.com.tr/ui" 
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">

    <ui:define name="content">

        <f:view>

            <h:form>
                <p:messages id="mensajes"
                            showDetail="true"/>
                <h:panelGrid columns="2" 
                             id="panel">
                    <h:outputLabel value="#{bundle.nit}:" 
                                   for="nit" />
                    <p:inputText id="nit"  
                                 value="#{empresaManagedBean.empresa.nit}" 
                                 title="#{bundle.nit}" 
                                 required="true" 
                                 requiredMessage="#{bundle.nit} #{bundle.campo_requerido}"/>

                    <h:outputLabel value="#{bundle.razon_social}:" for="razonSocial" />
                    <p:inputText id="razonSocial" 
                                 value="#{empresaManagedBean.empresa.razonSocial}" 
                                 title="#{bundle.razon_social}" 
                                 required="true" 
                                 requiredMessage="#{bundle.razon_social} #{bundle.campo_requerido}"/>

                    <h:outputLabel value="Email:" 
                                   for="email" />
                    <p:inputText id="email" 
                                 value="#{empresaManagedBean.empresa.email}" 
                                 title="#{bundle.email}" 
                                 required="true" 
                                 requiredMessage="#{bundle.email} #{bundle.campo_requerido}"/>
                    <h:outputLabel value="#{bundle.direccion}:" 
                                   for="direccion" />
                    <p:inputText id="direccion" 
                                 value="#{empresaManagedBean.empresa.direccion}" 
                                 title="#{bundle.direccion}" 
                                 required="true" 
                                 requiredMessage="#{bundle.direccion} #{bundle.campo_requerido}"/>
                    <h:outputLabel value="#{bundle.descripcion}:" 
                                   for="descripcion" />
                    <p:inputTextarea id="descripcion" 
                                     value="#{empresaManagedBean.empresa.descripcion}" 
                                     title="#{bundle.descripcion}" 
                                     required="true" 
                                     requiredMessage="#{bundle.descripcion} #{bundle.campo_requerido}"/>
                </h:panelGrid>
                <span/><span/>
                <p:commandButton image="ui-icon ui-icon-disk"  value="#{bundle.guardar}"
                                 update="@form"
                                 action="#{empresaManagedBean.guardar(actionEvent)}"/>
                <span/><span/>
                <p:commandButton image="ui-icon ui-icon-document"  value="#{bundle.nuevo}"
                                 action="#{empresaManagedBean.nuevoRegistro(actionEvent)}"
                                 update="@form" />
                <span/><span/>
                <p:commandButton image="ui-icon ui-icon-trash" value="#{bundle.eliminar}"
                                 update="@form"
                                 action="#{empresaManagedBean.eliminar(actionEvent)}"
                                 />
                <p:dataTable   id="tabla" 
                               value="#{empresaManagedBean.empresas}" 
                               var="item"   
                               selectionMode="single" 
                               selection="#{empresaManagedBean.empresaSeleccionada}" 
                               onRowSelectUpdate="panel" 
                               rowSelectListener="#{empresaManagedBean.seleccionarRegistro()}"
                               emptyMessage="#{bundle.no_existen_registros}">
                    <p:column  filterBy="#{item.nit}" 

                               filterMatchMode="contains" >
                        <f:facet name="header">
                            <h:outputText value="#{bundle.nit}"/>
                        </f:facet>
                        <h:outputText value="#{item.nit}"/>
                    </p:column>scontent
                    <p:column filterBy="#{item.razonSocial}" 
                              filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputText value="#{bundle.razon_social}"/>
                        </f:facet>
                        <h:outputText value="#{item.razonSocial}"/>
                    </p:column>
                    <p:column >
                        <f:facet name="header">
                            <h:outputText value="#{bundle.direccion}"/>
                        </f:facet>
                        <h:outputText value="#{item.direccion}"/>
                    </p:column>
                    <p:column >
                        <f:facet name="header">
                            <h:outputText value="#{bundle.email}"/>
                        </f:facet>
                        <h:outputText value="#{item.email}"/>
                    </p:column>

                </p:dataTable>
            </h:form>
        </f:view>
    </ui:define>

</ui:composition>
